package com.wzc.hc.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wzc.hc.entity.po.Region;
import com.wzc.hc.entity.resp.Result;
import com.wzc.hc.service.RegionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*
    @author: m1825
    @date: 2025/3/2 16:22
*/
@Tag(name = "地区")
@RestController
@RequestMapping("/region")
public class RegionController {
    @Autowired
    private RegionService regionService;

    @GetMapping("/getRegionById/{id}")
    public Result<List<Region>> getRegionById(@PathVariable("id") Integer id) {
        QueryWrapper<Region> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        return Result.ok(regionService.list(wrapper));
    }

    @GetMapping("/getRegionByPid/{pid}")
    public Result<List<Region>> getRegionByPid(@PathVariable("pid") Integer pid) {
        QueryWrapper<Region> wrapper = new QueryWrapper<>();
        wrapper.eq("pid", pid);
        return Result.ok(regionService.list(wrapper));
    }
}